package com.suray.wcs.web.system.jwt.exception;

import com.suray.wcs.web.system.jwt.model.ResultCode;

import java.text.MessageFormat;

/**
 * @author caox@suray.cn
 * @description:自定义异常类型
 * @date 2020/7/20 15:29
 */
public class CustomException extends RuntimeException {

    /**
     * 错误代码
     */
    ResultCode resultCode;

    public CustomException(ResultCode resultCode) {
        super(resultCode.message());
        this.resultCode = resultCode;
    }

    public CustomException(ResultCode resultCode, Object... args) {
        super(resultCode.message());
        String message = MessageFormat.format(resultCode.message(), args);
        resultCode.setMessage(message);
        this.resultCode = resultCode;
    }

    public ResultCode getResultCode() {
        return resultCode;
    }

}
